package com.linked.gateway.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author :dbq
 * @date : 2022/9/20 9:19
 * IP访问控制配置类
 */
@Configuration
@ConfigurationProperties("ipaccesscontrolconfig")
public class IPAccessControlConfig {


    
    /**
     * IP访问控制配置集合
     */
    private List<IPAccessControlInfo> ipAccessControls;

    public List<IPAccessControlInfo> getIpAccessControls() {
        return ipAccessControls;
    }

    public void setIpAccessControls(List<IPAccessControlInfo> ipAccessControls) {
        this.ipAccessControls = ipAccessControls;
    }

    public static class IPAccessControlInfo {
        /**
         * 控制类型：
         * 白名单：white
         * 黑名单：black
         */
        private String controlType;
        /**
         * 访问格式：
         * ip、路径
         */
        private String accessValue;
        /**
         * 网站名称
         */
        private String ipName;

        public String getControlType() {
            return controlType;
        }

        public void setControlType(String controlType) {
            this.controlType = controlType;
        }

        public String getAccessValue() {
            return accessValue;
        }

        public void setAccessValue(String accessValue) {
            this.accessValue = accessValue;
        }

        public String getIpName() {
            return ipName;
        }

        public void setIpName(String ipName) {
            this.ipName = ipName;
        }
    }

    @Override
    public String toString() {
        return "IPAccessControlConfig{" +
                "ipAccessControls=" + ipAccessControls +
                '}';
    }
}
